package com.d4a5.mapping.google2
{
	import com.google.maps.overlays.OverlayBase;
	
	import flash.display.DisplayObject;
	
	public class wmgOverlayBase extends OverlayBase
	{
		protected var _shapes:Array;
		
		public function wmgOverlayBase()
		{
			this._shapes = new Array();
			super();
		}
		
		
		public function get shapes() : Array {
			return this._shapes;
		}
		
		override public function addChild(child:DisplayObject):DisplayObject {
			this._shapes.push( child );
			return super.addChild( child );
		}
		
		override public function addChildAt(child:DisplayObject, index:int):DisplayObject{
			this._shapes.splice( index , 0 , child );
			return super.addChildAt( child , index );
		}
		
		override public function removeChild(child:DisplayObject):DisplayObject{
			return super.removeChild( child );
		}
		
		override public function removeChildAt(index:int):DisplayObject {
			this._shapes.splice( index , 1 );
			return super.removeChildAt( index );
		}
		
		override public function swapChildrenAt(index1:int, index2:int):void {
			var obj1:Object = this._shapes[index1];
			var obj2:Object = this._shapes[index2];
			this._shapes.splice( index1 , 1 , obj2 );
			this._shapes.splice( index2 , 1 , obj1 );
			super.swapChildrenAt( index1 , index2 );
		}
		
		override public function setChildIndex(child:DisplayObject, newIndex:int):void {
			var index:int = super.getChildIndex(child);
			this._shapes.splice( newIndex , 0 , this._shapes.splice( index , 1 )[0] );
			super.setChildIndex( child , newIndex );
		}
	}
}